package com.nju.mini_tiktok.API;

import com.nju.mini_tiktok.bean.DataCreate;

import java.io.IOException;
import java.util.List;
import java.util.Objects;

import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class APIhelper {
    public void getVideos(){
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("https://beiyou.bytedance.com/")
                .addConverterFactory(GsonConverterFactory.create()) //添加Gson
                .build();

        APIservice apiService = retrofit.create(APIservice.class);
        Call<List<VideoItem>> call = apiService.getVideos();
        try {
            new DataCreate().initData(Objects.requireNonNull(call.execute().body()));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
